package net.sunniwell.flowview.proxy;

import android.support.annotation.IntDef;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;


public class SWProxyTest {
    public static void main(String[] args) {
        final A a = new A();

        Object o = Proxy.newProxyInstance(SWProxyTest.class.getClassLoader(), new Class[]{Wash.class, Message.class}, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("method invoke");
                if(method.isAnnotationPresent(IntDef.class)){

                }
                return method.invoke(a,args);
            }
        });

        Wash  washer = (Wash) o;
        ((Wash) o).wash();



    }


    public interface Wash {

        void wash();

    }


    public interface Message {
        void message(String msg);
    }


    public static class A implements  Wash{

        @Override
        public void wash() {
            System.out.println("A wash your hands.");
        }
    }

}

